home *** CD-ROM | disk | FTP | other *** search
- From: aem@aber.ac.uk (Alec David Muffett)
- Newsgroups: alt.security
- Subject: Re: Setuid shell scripts, Whats the problem?
- Message-ID: <1992Feb4.170623.5192@aber.ac.uk>
- Date: 4 Feb 92 17:06:23 GMT
- References: <1992Feb2.114728.27168@matilda.vut.edu.au> <1992Feb3.003936.9693@rz.uni-karlsruhe.de> <1992Feb03.191612.198991@cs.cmu.edu>
- Organization: University College of Wales, Aberystwyth
-
- In article <1992Feb03.191612.198991@cs.cmu.edu> bsy+@cs.cmu.edu writes:
- >In article <1992Feb3.003936.9693@rz.uni-karlsruhe.de>, chris@rz.uni-karlsruhe.de (Christian Finger) writes:
- >>
- >> Solution:
- >> You need another binary program.
- >> This program takes a pathname as parameter, expands all symbolic links etc.
- >> in it (using realpath() .e.g) and exec()s the shell with the absolute
- >> pathname as paramter. To use this program you have to put the
- >> the pathname of it in the #! line at the beginning of your skript.
- >>
- >>Are you shure using a shell skript is easier then writing a C program ?
- >
- >Symbolic links are one way to exploit this bug. Another is to use a
- >hard link when you have a writable directory in the same partition as
- >the setuid shell script. Using a hard link defeats the solution
- >outlined above.
-
- Actually guys, there is a simpler way to hack most setuid shell scripts...
-
- when the kernel is told to exec a shell script names "fred"
- which contains the line "#!/bin/sh"
- it builds the line "/bin/sh fred"
- goes setuid
- and execs that...
-
- If you make a symlink to fred called "-i"
- and execute "-i"
- the kernel builds the line "/bin/sh -i"
- goes setuid
- and execs that...
-
- Whammo - an interactive setuid bourne shell...
-
- > Don't use setuid shellscripts
-
- Right on, brother...
-
- - alec
-
- ObHack: A one line, infinitely recursive shellscript:-
- ------------
- #!/bin/sh -c
- ------------
-
- --
- |+ Alec David Edward Muffett, Unix Programmer and Unemployed Coffee Drinker. +|
- |> aem@aber.ac.uk aem@uk.ac.aber aem%aber@ukacrl.bitnet mcsun!ukc!aber!aem <|
- | "I didn't invent the Unix Password Security problem. I just optimised it." |
-
-